package com.fqj.fqjgateway;

import com.template.project.provider.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Service;

//忽略数据库
@SpringBootApplication(exclude = {
		DataSourceAutoConfiguration.class,
		DataSourceTransactionManagerAutoConfiguration.class,
		HibernateJpaAutoConfiguration.class})
@EnableDubbo
@Service
@Slf4j
public class FqjGatewayApplication {
	@DubboReference
	private DemoService demoService;//真他妈的奇怪，虽然爆红，但是可以运行。

	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(FqjGatewayApplication.class, args);
		FqjGatewayApplication application = context.getBean(FqjGatewayApplication.class);
		String result = application.doSayHello("world");
		String result2 = application.doSayHello2("world");
		System.out.println("result: "+result);
		System.out.println("result: "+result2);
		log.info("项目启动成功");
	}
	public String doSayHello(String name){ return demoService.sayHello(name);}//不管了，反正可以运行。
	public String doSayHello2(String name){return demoService.sayHello2(name);}

	// @Bean
	// public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
	// 	return builder.routes()
	// 			.route("tobaidu", r -> r.path("/baidu")
	// 					.uri("https://www.baidu.com"))
	// 			.route("toyupiicu", r -> r.path("/yupiicu")
	// 					.uri("http://yupi.icu"))
	// 			.build();
	// }
}
